package expenager.project.two;

import java.text.SimpleDateFormat;
import java.util.Calendar;

import android.app.Activity;
import android.content.Intent;
import android.database.Cursor;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

public class ExpenagerActivity extends Activity {
    /** Called when the activity is first created. */
    
	Button btnPreferences, btntransaction;
	TextView textViewDate,test;
	Calendar calendar;
	//DatabaseHelper dbHelper;
	DBAdapter db = new DBAdapter(this);
	//DBCurrentSetting dbSetting = new DBCurrentSetting(this);
	
	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //dbHelper = new DatabaseHelper(this);
        db.open();
        Cursor c = db.getSettingIncome();
        	
        c.moveToLast();
        	
        db.close();
        //c.getString(0)
    	//Integer.toString(c.getPosition())
        Toast.makeText(getApplicationContext(), Integer.toString(c.getPosition()), Toast.LENGTH_SHORT).show();
        //test.setText(textTest.toString());
        //testInsert();
        //test();
        //getCurrency();
        setDate();
                
        btnPreferences = (Button) findViewById(R.id.btnPreferences);
        btnPreferences.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(),preferences.class);
				startActivity(i);
			}
		});
        
        btntransaction = (Button) findViewById(R.id.butrans);
        btntransaction.setOnClickListener(new View.OnClickListener() {
			
			public void onClick(View v) {
				// TODO Auto-generated method stub
				Intent i = new Intent(getApplicationContext(),transaction.class);
				startActivity(i);
			}
		});
        
	}
	
	/*public void getCurrency() {
		//Cursor c = dbHelper.getCurrency();
		
		test = (TextView) findViewById(R.id.textViewTest);
		test.setText("aa");
		//c.getString(0);
	}*/
	
	/*public void testInsert() {
		db.open();
		db.insertTest();
		db.close();
	}*/
	
	/*public void test() {
		db.open();
		Cursor c = db.getCurrency();
		c.moveToNext();
		test = (TextView) findViewById(R.id.textViewTest);
		test.setText(Integer.toString(c.getInt(0)));
		
		db.close();
	}*/
	
	public void setDate() {
		calendar = Calendar.getInstance();
		
		SimpleDateFormat day_num = new SimpleDateFormat("EEE");
		String day = day_num.format(calendar.getTime());
		
		String date = Integer.toString(calendar.get(Calendar.DATE));
		
		SimpleDateFormat month_num = new SimpleDateFormat("MMM");
		String month = month_num.format(calendar.getTime());
		
		String year = Integer.toString(calendar.get(Calendar.YEAR));
		
		textViewDate = (TextView) findViewById(R.id.textViewDate);
		textViewDate.setText(day+", "+date+" "+month+" "+year);
	}
}